home *** CD-ROM | disk | FTP | other *** search
- Path: imaginet.fr!usenet
- From: URBANY <systec@imaginet.fr>
- Newsgroups: comp.lang.c++
- Subject: Re: Typecasting a class? Help!
- Date: 29 Mar 1996 10:14:11 GMT
- Organization: ImagiNET
- Message-ID: <4jgd5j$1ld@avalon.imaginet.fr>
- References: <dkelly.828048898@maestro.inav.net>
- NNTP-Posting-Host: cyber25.imaginet.fr
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
-
- dkelly@blue.weeg.uiowa.edu (Dave Kelly) wrote:
- > ...
- >
- >But it doesn't work unless I do this:
- >
- >printf("clInteger is equal to %d\n", (int)clInteger);
- >
-
- It doesn't work because printf has only one declared argument. printf prototype
- if (by memory) in printf(const char*, ...).
- So the compiler can't figure what is the type of your clInteger argument, and then
- it can't cast it.
-
- Secondly, in C++, it is better to use iostream << operators instead of printf. Then
- the comiler knows how to do :
- cout << clInteger.
-
- Hope this help
-
- Nicolas CAILLAUD
-
-
-